<?php

namespace plugin\admin\app\model;

use plugin\admin\app\model\Base;

/**
 * @property integer $id (主键)
 * @property integer $user_id 用户ID
 * @property integer $label_id 标签ID
 * @property string $new_level 物品新度
 * @property string $thumb 交易封面
 * @property string $title 交易标题
 * @property float $longitude 经度
 * @property float $latitude 纬度
 * @property string $province 省
 * @property string $city 市
 * @property string $district 区
 * @property string $address 详细地址
 * @property string $contact_name 联系人
 * @property string $contact_mobile 联系手机号
 * @property string $expect_exchange 期望置换
 * @property string $price 原价值
 * @property string $content 商品介绍
 * @property integer $created_time 创建时间
 * @property integer $is_enable 是否启用
 */
class Exchange extends Base
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wa_exchanges';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';
    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    const STATUS_WAIT_EXCHANGE = 1;

    const STATUS_FINISH_EXCHANGE = 2;

    public static function getStatusText($exchange)
    {
        if (!$exchange['is_up']) {
            return '已下架';
        }

        switch ($exchange['status']) {
            case self::STATUS_WAIT_EXCHANGE:
                return '待交换';
            case self::STATUS_FINISH_EXCHANGE:
                return '已交换';
        }
    }
}
